package com.yyh.synctool.server.exception.handle;

import com.yyh.result.JsonResult;
import com.yyh.synctool.server.exception.IllegalIdentityException;
import com.yyh.synctool.server.exception.code.AccessErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 访问异常处理
 * @author xuan
 * @create 2021/12/18
 */
@Slf4j
@Order(1)
@RestControllerAdvice
public class AccessExceptionHandle
{
    /** 非法访问 */
    @ExceptionHandler(IllegalIdentityException.class)
    public JsonResult illegalAccessException(IllegalIdentityException e) {
        log.warn("非法身份访问--> 原因：{}", e.getMessage());
        return JsonResult.getResult(AccessErrorCode.ILLEGAL_IDENTITY_ERROR);
    }

}
